<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML>
<html>
<head>

<title>My JSP 'main.jsp' starting page</title>
<script type="text/javascript" src="script/jquery.js"></script>
<link href="style/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="script/bootstrap-modal.js"></script>


<style type="text/css">
.span8 {

	padding-left: 30%;
}

.span8 {
	padding-right: 80%;
}

#three_button {
	padding-left: 55%;
}

.pagination {
	padding-left: 40%;
}
body{
	width:auto;
	
}
</style>

</head>

<body>
	<div class="navbar">
		<div class="navbar-inner">
			<div class="container" style="width: auto;">
				<a class="btn btn-navbar" data-target=".nav-collapse"
					data-toggle="collapse"> <span class="icon-bar"></span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> </a> <a
					class="brand" href="#">品竹缘健康生活馆</a>
				<div class="nav-collapse">
					<ul class="nav">
						<li class="active"><a href="#">首页</a>
						</li>
						<li class="active"><a href="#">用户管理</a>
						</li>
					</ul>

					<ul class="nav pull-right">
						<li class="divider-vertical"></li>
						<li><a href="#">${juese}</a>
						</li>
					</ul>
				</div>
			</div>
		</div>
	</div>

	<div id="three_button">

		<a class="btn btn-info" href="main.jspx?task=main"><i
			class="icon-home icon-white"></i>所有记录</a> <a class="btn btn-success"
			href="add.jspx?task=add&info=admin">添加新纪录</a> <a id="serachjilu"
			class="btn btn-primary" href="javascript:void(0)">搜索记录</a> <a
			class="btn" href="main.jspx?task=excel" id="export">导出excel</a>

	</div>

	<div class="span8">
		<table class="table table-striped">
			<thead>
				<tr>
					<th>时间</th>
					<th>单位</th>
					<th>导游</th>
					<th>客源地</th>
					<th>人数</th>
					<th>销售额</th>
					<th>客单价</th>
					<th>操作</th>
					<th></th>
				</tr>
			</thead>

			<tbody>
				<c:if test="${empty all }">
					<tr>
						<td colspan="3">暂时没有数据.....</td>
					</tr>
				</c:if>
				<c:forEach var="s" items="${all }">
					<tr>
						<td>${s.time }</td>
						<td>${s.compname }</td>
						<td>${s.trname }</td>
						<td>${s.from }</td>
						<td>${s.num }</td>
						<td>${s.totalmoney }</td>
						<td>${s.unitmoney }</td>

						<td><a href="main.jspx?task=edit&id=${s.id }">编辑</a> <a
							class="delete" rel="main.jspx?task=del&id=${s.id }"
							href="javascript:void(0)">删除</a></td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>

	<div class="offset7">
		

		<span class="prompt">当前页记录数::${sum }条</span> <span class="prompt">当前页总销售额:${sumtotal}元</span>
		<span class="prompt">当前页总人数:${sumpeople }人</span> <span class="prompt">当前页平均客单价:${unitpeople}元</span>

	</div>
	<hr />
	<div class="offset7">
		<span class="prompt">总记录数::${allSaleSum }条</span> <span class="prompt">总销售额:${allSaleMoney}元</span>
		<span class="prompt">总人数:${allsaleSumPeople }人</span> <span
			class="prompt">平均客单价:${allSalesUnit}元</span>
	</div>

	<div class="pagination">
		<ul>
			<li><a id="firstpage" class="pagenum" rel="0"
				href="javascript:void(0)">首页</a>
			</li>

			<li><a id="before" href="javascript:void(0)">上一页</a>
			</li>

			<c:forEach var="pagenum" items="${pagenum}">
				<li><a class="pagenum" rel="${pagenum-1}"
					href="javascript:void(0)">${pagenum}</a></li>
			</c:forEach>

			<li><a id="next" href="javascript:void(0)">下一页</a>
			</li>

			<li><a id="lastpage" class="pagenum" rel="${page.maxPage-1}"
				href="javascript:void(0)">尾页</a>
			</li>
		</ul>
	</div>


	<%--分页的隐藏域 --%>
	<input id="nowpage" type="hidden" style="display:none"
		value="${page.nowPage } " />

	<%--搜索的隐藏域 --%>
	<div id="serach" class="modal hide fade" style="display: none;">
		<div class="modal-header">
			<a class="close" data-dismiss="modal">×</a>
			<h3>搜索</h3>
		</div>
		<div class="modal-body">
			<div class="control-group">
				<form id="form1" action="search.jspx?task=search" method="post">
					<label class="control-label" for="focusedInput"> 日期 </label>
					<div class="controls">
						<input id="focusedInput" class="input-xlarge focused" type="text"
							name="starttime">到<input id="focusedInput"
							class="input-xlarge focused" type="text" name="endtime">
					</div>

					<label class="control-label" for="focusedInput"> 单位 </label>
					<div class="controls">
						<input id="focusedInput" class="input-xlarge focused" type="text"
							name="danwei">
					</div>

					<label class="control-label" for="focusedInput"> 导游 </label>
					<div class="controls">
						<input id="focusedInput" class="input-xlarge focused" type="text"
							name="tr">
					</div>

					<label class="control-label" for="focusedInput"> 人数 </label>
					<div class="controls">
						<input id="focusedInput" class="input-xlarge focused" type="text"
							name="minnum">到<input id="focusedInput" class="input-xlarge focused" type="text"
							name="maxnum">
					</div>

					<label class="control-label" for="focusedInput"> 客源地 </label>
					<div class="controls">
						<input id="focusedInput" class="input-xlarge focused" type="text"
							name="from">
					</div>

					<label class="control-label" for="focusedInput"> 销售额 </label>
					<div class="controls">
						<input id="focusedInput" class="input-xlarge focused" type="text"
							name="mintotal">到<input id="focusedInput"
							class="input-xlarge focused" type="text" name="maxtotal">
					</div>
				</form>
			</div>
		</div>
		<div class="modal-footer">
			<a id="searchbtn" class="btn btn-primary" href="javascript:void(0)">搜索</a>
			<a class="btn" data-dismiss="modal" href="#">Close</a>
		</div>
	</div>

	<%---删除的隐藏域 --%>
	<div id="myModal" class="modal hide fade" style="display: none;">
		<div class="modal-header">
			<a class="close" data-dismiss="modal">×</a>
			<h3>删除提示</h3>
		</div>
		<div class="modal-body">
			<h4>确定删除</h4>
		</div>
		<div class="modal-footer">
			<a id="delete" class="btn btn-primary" href="javascript:void(0)">删除</a>
			<a class="btn" data-dismiss="modal" href="#">Close</a>
		</div>
	</div>

</body>
<script type="text/javascript">
	$(function() {
		var myurl;
		active();
		$("#before").click(function() {
			var nowP = parseInt($("#nowpage").val());
			if (nowP == 0) {
				return false;
			}
			nowP = nowP - 1;
			if (nowP < 0) {
				nowP = 0;
			}

			window.location.href = "main.jspx?task=page&page=" + nowP;
		});
		$("#next").click(function() {
			var nextP = parseInt($("#nowpage").val());

			if (nextP == $("#lastpage").attr("rel")) {
				return false;
			}
			var m = parseInt($("#lastpage").attr("rel"));
			nextP = nextP + 1;
			if (nextP > m) {
				nextP = m;
			}
			window.location.href = "main.jspx?task=page&page=" + nextP;
		});

		$(".pagenum").click(function() {
			var page = $(this).attr("rel");
			if (page == $("#nowpage").val()) {
				return false;
			}
			window.location.href = "main.jspx?task=page&page=" + page;

		});

		function active() {
			$(".pagenum").parent().removeClass();
			$("#before").parent().removeClass();
			$("#next").parent().removeClass();
			$(".pagenum[rel='" + $("#nowpage").val() + "']").parent().addClass(
					"active");
			if ($("#nowpage").val() == 0) {
				$("#prev").parent().addClass("active");
			}
			if ($("#nowpage").val() == ($("#lastpage").attr("rel"))) {
				$("#next").parent().addClass("active");
			}
		}

		$(".delete").click(function() {
			myurl = $(this).attr("rel");
			$("#myModal").modal("show");
		});

		$("#delete").click(function() {
			window.location.href = myurl;
		});

		$("#serachjilu").click(function() {
			$("#serach").modal("show");
		});

		$("#searchbtn").click(function() {
			$("#serach").modal("hide");
			$("#form1").submit();
		});
		$("#export").click(function() {
			myurl = $(this).attr("rel");
		});

	});
</script>

</html>